#pragma once

#ifdef LINUX

#include "SystemWindowInterface.h"


#include <X11/Xlib.h>

class CX11Window : public ISytemWindowInterface
{
public: 
    CX11Window();
    ~CX11Window();

    uint64_t GetWindowID() const override;

    //get window content position in screen
    virtual SIntPoint GetContentPosition() const override;

    //get window content size 
    virtual SIntPoint GetContentSize() const override;

    SIntPoint GetWindowSize() const override;

    void SetWindowSize(SIntPoint InSize) override;

    SIntPoint GetWindowPosition() const override;

    void SetWindowPosition(SIntPoint InPosition) override;

    void MoveToScreenCenter() override;

    void SetWindowTitle(const CString &InTitle) override;

    SRect GetScreenPlacableArea() override;

    bool IsMaximized() const override;

    void Maximize() override;

    bool IsNormalSizeAndPosition() const override;

    void Restore() override;

    bool IsMinimized() const override;

    void Minimize() override;

    bool IsFullScreen() const override;

    void FullScreen() override;

    virtual void ShowBorder() override;
    
    virtual void HideBorder() override;

    virtual bool IsBorderVisible() const override;
    // void StartCaptureMouse() override;
    
    // void StopCaptureMouse() override;

    vk::SurfaceKHR CreateVkSurfaceKHR(vk::Instance Instance) override;

    void Show() override;

    void Hide() override;

    bool IsVisible() const override;

    void SetOpcity(float InOpacity) override;

    //enable/disable this window
    //if disable, this window will not receive any input event
    void EnableThisWindow(bool bEnable) override;
    bool IsThisWindowEnabled() const override;

    //bring this window to front
    void BringToFront() override;

    //hide this window in taskbar
    void HideInTaskbar() override;

protected:
    Window WindowID;

    Display* GetDisplay() const;

    // SIntPoint WindowSize;
    // SIntPoint WindowPosition;

    enum class EX11WindowSizeState
    {
        Normal,
        Maximized,
        Minimized,
        FullScreen
    };

    //EX11WindowSizeState SizeState= EX11WindowSizeState::Normal;

    void RestoreFromMaximized();
    void RestoreFromMinimized();
    void RestoreFromFullScreen();

    friend class CLinuxPlatform;

    // //window that now capture mouse
    // static Window CaptureMouseWindow;

    // bool bIsMapped = false;

    // //可见性！＝窗口是否映射
    // //因为窗口大小为0时，窗口也不会映射，但是在逻辑上认为窗口是可见的
    // bool bIsVisible = false; 
};


#endif